package com.franklin.validation.core.argument.impl.string;

import com.franklin.validation.core.annotations.Resolver;
import com.franklin.validation.core.annotations.WebFluxFormDataComponent;
import com.franklin.validation.core.constants.Constants;
import com.franklin.validation.core.entity.CheckFormEntity;
import com.franklin.validation.core.utils.DataCheckUtil;

import java.util.Date;

/**
 * Description :
 * Create By: Franklin
 * Date : 2020/6/15 16:06
 */
@Resolver(Date.class)
@WebFluxFormDataComponent
public class DateResolverResult extends AbstractStringResolverResult<String> {
    @Override
    public String onError(CheckFormEntity input) {
        return Constants.EMPTY;
    }

    @Override
    public String getResult(CheckFormEntity input) {
        return this.getStringValue(input.getValues());
    }

    @Override
    protected boolean checkPattern(String value, String pattern) {
        return DataCheckUtil.checkDate(value, pattern);
    }

}
